package demo9Polymorphism;

class Shape{
    public void graph(){
        System.out.println("画一个图形!");
    }
}
class Circle extends Shape{
    @Override
    public void graph() {
        System.out.println("⚪");
    }
}
class Fount extends Shape{
    @Override
    public void graph() {
        System.out.println("♦");
    }
}
class Triangle extends Shape{
    @Override
    public void graph() {
        System.out.println("▲");
    }
}


public class TestDemo {

    public static void drawMap(Shape shape){
        shape.graph();
    }

    public static void main(String[] args) {
        Circle circle = new Circle();
        Fount fount = new Fount();
        Triangle triangle = new Triangle();
        Shape[] shapes = {circle,fount,circle,fount,triangle};
        for (Shape shape:shapes) {
            shape.graph();
        }
    }

    public static void main1(String[] args) {

        Circle circle = new Circle();
        Fount fount = new Fount();
        Triangle triangle = new Triangle();
        drawMap(circle);
        drawMap(fount);
        drawMap(triangle);

    }
}
